//
//  DeviceMangers.swift
//  JXBaseTools
//
//  Created by godox on 2021/11/30.
//

import UIKit


public extension CGSize {
    
    enum Device {
        case iPhone4
        case iPhone5
        case iPhone6
        case iPhone6Plus
        case iPhoneX
        case iPhoneXR
        case iPhoneXS
        case iPhoneXSMax
        
        var size: CGSize {
            switch self {
            case .iPhone4:      return CGSize.init(width:  640, height:  960)   //1.5
            case .iPhone5:      return CGSize.init(width:  640, height: 1136)   //1.775
            case .iPhone6:      return CGSize.init(width:  750, height: 1334)   //1.778
            case .iPhone6Plus:  return CGSize.init(width: 1242, height: 2208)   //1.777
            case .iPhoneX:      return CGSize.init(width: 1125, height: 2436)   //2.165
            case .iPhoneXR:     return CGSize.init(width:  828, height: 1792)   //2.164
            case .iPhoneXS:     return CGSize.init(width: 1125, height: 2436)   //2.165
            case .iPhoneXSMax:  return CGSize.init(width: 1242, height: 2688)   //2.164
            }
        }
        
    }
    
}

public extension UIDevice {
    static var isIPhone4: Bool{
        return UIScreen.main.currentMode!.size.equalTo(CGSize.Device.iPhone4.size)
    }
    static var isIPhone5: Bool {
        return UIScreen.main.currentMode!.size.equalTo(CGSize.Device.iPhone5.size)
    }
    static var isIPhone6: Bool {
        return UIScreen.main.currentMode!.size.equalTo(CGSize.Device.iPhone6.size)
    }
    static var isPhone6Plus: Bool {
        return UIScreen.main.currentMode!.size.equalTo(CGSize.Device.iPhone6Plus.size)
    }
    static var isIPhoneX: Bool {
        return UIScreen.main.currentMode!.size.equalTo(CGSize.Device.iPhoneX.size)
    }
    static var isIPhoneXR: Bool {
        return UIScreen.main.currentMode!.size.equalTo(CGSize.Device.iPhoneXR.size)
    }
    static var isIPhoneXS: Bool {
        return UIScreen.main.currentMode!.size.equalTo(CGSize.Device.iPhoneXS.size)
    }
    static var isIPhoneXSMax: Bool {
        return UIScreen.main.currentMode!.size.equalTo(CGSize.Device.iPhoneXSMax.size)
    }
}



/// 判断是否 ipad
public let isPad: Bool = (UIDevice.current.userInterfaceIdiom == .pad)
/// 判断是否 iphone
public let isPhone: Bool = (UIDevice.current.userInterfaceIdiom == .phone)

public let isPhoneX = UIDevice.isIPhoneX || UIDevice.isIPhoneXR || UIDevice.isIPhoneXS || UIDevice.isIPhoneXSMax

